{extend name="pub/base" /}
{block name="title"}
<title>充值码生成</title>
{/block}
{block name="body"}
<div class="Hui-admin-article">
    <div class="Hui-article">
        <article class="clearfix pd-20">
            <form class="form form-horizontal">
                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>充值卡面额：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="{$chargecode_money}" name="chargecode_money">
                    </div>
                </div>

                <div class="row clearfix">
                    <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>充值码生成个数：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="{$chargecode_num}" name="chargecode_num">
                    </div>
                </div>


                <div class="row clearfix">
                    <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                        <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
                        <a href="{:url('chargecodes/index')}" class="btn btn-success radius">返回</a>
                    </div>
                </div>
            </form>
        </article>
    </div>
</div>
<script>
    $(function () {
        $("form").validate({
            rules: {
                chargecode_money: {
                    required: true,
                    digits: true
                },
                chargecode_num:{
                    required: true,
                    digits: true
                }
            },
            onkeyup: false,
            focusCleanup: false,
            submitHandler: function(form) {
                layer.open({
                    type: 1,
                    title: false,
                    area: ['630px', '360px'],
                    content: '<p></p><p style="padding-left:15px;font-weight: 400;color:#999;">生成中，请耐心等待</p>'
                });

                $.ajax({
                    url: "{:url('chargecodes/gencodes')}",
                    type: 'post',
                    data: $("form").serialize(),
                    success(data){
                        $('.layui-layer-content').append(data);
                    }
                })
            }
        });
    });
</script>
{/block}